|
|
|
|
|
|
|
It is very common to have fields on your form that require special input formats. Examples of special formats would be telephone numbers, Social Security numbers, hour/minute time entry, and so on. Visual Basic 5 ships with a bound data control that handles special input and display formattingthe MaskedEdit control. The MaskedEdit control works like the standard Visual Basic 5 textbox control, with a few added properties that make it a powerful tool for your input validation arsenal. |
|
|
|
|
|
|
|
|
Let's add a phone number input field to the form. Add a new label to the form and set its caption property to Phone. Now add a MaskedEdit control to the form. Set its Name property to mskPhone, the Mask property to (###) ###-#### and the PromptInclude property to False. |
|
|
|
|
| |
|
|
|
|
It is essential that you set the PromptInclude property to False when using the MaskedEdit control as a bound control. If the PromptInclude property is set to True, you get a database error each time you add a new record to the table or attempt to save or read a record that has a null value in the data field linked to the MaskedEdit bound control. |
|
|
|
|
|
|
|
|
|
|
Your form should resemble Figure 5.4. |
|
|
|
|
|
|
|
|
Figure 5.4.
Adding the MaskedEdit
Phone control to the form. |
|
|
|
|
|
|
|
|
You do not need to add any additional filtering to the control because the MaskedEdit control makes sure that only digits are entered and that the input is limited to 10 digits formatted as a standard U.S. phone number. |
|
|
|
|
|